package com.tencent.sr.iris.activity.restapi.activity;

import com.tencent.sr.iris.activity.interfaces.client.activity.UserTaskStaticClient;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityStaticRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityUserStaticRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.AwardStaticRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.LongTermAwardStaticRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.LowerLevelUserCountRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.UserActivityInfoRequest;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityStaticResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityUserStaticResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.AwardStaticResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.LongTermAwardStaticResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.UserActivityInfoResponse;
import com.tencent.sr.iris.activity.service.activity.IrisUserTaskRecordService;
import com.tencent.sr.iris.activity.service.activity.UserTaskStatisticsService;
import com.tencent.sr.iris.user.core.service.interfaces.response.user.UserLevelCountResponse;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 活动任务统计
 *
 * @author nixiaolin
 * @date 2023/2/15 18:02
 */
@Api(tags = "活动任务统计", value = "活动任务统计相关接口")
@RestController
@RequestMapping(value = {"/api/v1/iris/iris-activity-core-service/task/static"})
public class UserTaskStaticController implements UserTaskStaticClient {

    @Resource
    private IrisUserTaskRecordService userTaskRecordService;
    @Resource
    private UserTaskStatisticsService userTaskStatisticsService;

    /**
     * 长期激励统计
     *
     * @author nixiaolin
     * @date 2023/2/15 18:08
     */
    @Override
    @PostMapping("longTermAward")
    @ApiOperation(value = "长期激励统计", httpMethod = "POST")
    public HttpResult<LongTermAwardStaticResponse> longTermAward(
            @Validated @RequestBody LongTermAwardStaticRequest request) {
        LongTermAwardStaticResponse staticResponse = userTaskRecordService.longTermAwardStatic(request);
        return HttpResult.succ(staticResponse);
    }

    @Override
    @PostMapping("awardStatic")
    @ApiOperation(value = "活动收益统计", httpMethod = "POST")
    public HttpResult<AwardStaticResponse> awardStatic(@Validated @RequestBody AwardStaticRequest request) {
        AwardStaticResponse staticResponse = userTaskRecordService.awardStatic(request);
        return HttpResult.succ(staticResponse);
    }

    /**
     * 查询活动周期内上级用户的下级数量
     *
     * @author nixiaolin
     * @date 2023/2/15 18:08
     */
    @Override
    @PostMapping("lowerLevelUserCount")
    @ApiOperation(value = "查询活动周期内上级用户的下级数量", httpMethod = "POST")
    public HttpResult<List<UserLevelCountResponse>> lowerLevelUserCount(
            @Validated @RequestBody LowerLevelUserCountRequest request) {
        HttpResult<List<UserLevelCountResponse>> result = userTaskStatisticsService.lowerLevelUserCount(request);
        return result;
    }


    @Override
    @PostMapping("activityUserStatic")
    @ApiOperation(value = "活动参与用户统计", httpMethod = "POST")
    public HttpResult<ActivityUserStaticResponse> activityUserStatic(
            @Validated @RequestBody ActivityUserStaticRequest request) {
        ActivityUserStaticResponse staticResponse = userTaskRecordService.activityUserStatic(request);
        return HttpResult.succ(staticResponse);
    }

    @Override
    @PostMapping("userActivityInfo")
    @ApiOperation(value = "用户活动信息", httpMethod = "POST")
    public HttpResult<UserActivityInfoResponse> userActivityInfo(
            @Validated @RequestBody UserActivityInfoRequest request) {
        UserActivityInfoResponse staticResponse = userTaskRecordService.userActivityInfo(request);
        return HttpResult.succ(staticResponse);
    }

    @Override
    @PostMapping("activityStatic")
    @ApiOperation(value = "活动统计", httpMethod = "POST")
    public HttpResult<ActivityStaticResponse> activityStatic(
            @Validated @RequestBody ActivityStaticRequest request) {
        ActivityStaticResponse staticResponse = userTaskRecordService.activityStatic(request);
        return HttpResult.succ(staticResponse);
    }
}
